package com.zy.springboot.dao.user;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.zy.springboot.dao.BaseDao;
import com.zy.springboot.entity.IBaseEntity;
import com.zy.springboot.entity.user.UserEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created by y on 2019/1/11.
 */
@Repository
public class UserDao extends BaseDao {

    public UserDao(){
        super.iBaseEntity = new UserEntity();
    }

    @Override
    public IBaseEntity convertJson2Entity(JSONObject json) {
        return JSON.toJavaObject(json,UserEntity.class);
    }

    public List<JSONObject> getUserList() {
        StringBuffer sql=new StringBuffer();
        sql.append(" SELECT ID AS id, USERNAME AS userName,`PASSWORD` AS PASSWORD,");
        sql.append(" SEX AS sex,CREATE_TIME AS createTime,UPDATE_TIME as updateTime");
        sql.append(" FROM t_sys_user WHERE DEL_FLAG =0");
        return super.queryForJsonList(sql.toString());
    }
}
